package com.example.freeengine.wallpaper.persistence.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import com.example.freeengine.wallpaper.persistence.entity.WallPaperCycleRefreshAlbumItem;
import com.google.common.util.concurrent.ListenableFuture;

import java.util.List;

/**
 * @author Terry Deng
 */
@Dao
public interface WallPaperCycleRefreshAlbumItemDao {

    @Query("select count(*) from wallpaper_cyclerefresh_album_item where album_id = :id")
    LiveData<Integer> countByAlbumId(Long id);

    @Query("select * from wallpaper_cyclerefresh_album_item where album_id = :id order by refresh_order ASC")
    LiveData<List<WallPaperCycleRefreshAlbumItem>> findAllByAlbumIdLiveData(Long id);

    @Query("select * from wallpaper_cyclerefresh_album_item where album_id = :id order by refresh_order ASC")
    ListenableFuture<List<WallPaperCycleRefreshAlbumItem>> findAllByAlbumId(Long id);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    ListenableFuture<List<Long>> insert(List<WallPaperCycleRefreshAlbumItem> wallPaperCycleRefreshAlbumItemList);

    @Delete
    ListenableFuture<Integer> delete(WallPaperCycleRefreshAlbumItem wallPaperCycleRefreshAlbumItem);
}
